﻿using System;
using System.Collections.Generic;

using System.Text;
using ITAP.ShprossesBuilder.Modelling.Components;

namespace ITAP.ShprossesBuilder.Manipulation
{
    public delegate ModelContainer CreateModelContainerDelegate();

    public class CommandCreateModelContainer : IModelComponentCommand
    {
        private ModelControl modelControl;
        private CreateModelContainerDelegate createModelContainerDelegate;
        public CommandCreateModelContainer(ModelControl modelControl, CreateModelContainerDelegate createModelContainerDelegate)
        {
            this.modelControl = modelControl;
            this.createModelContainerDelegate = createModelContainerDelegate;
        }

        #region IModelComponentCommand Members

        public List<ITAP.ShprossesBuilder.Modelling.Components.IComponent> ComponentsForProcessing
        {
            get
            {
                return new List<ITAP.ShprossesBuilder.Modelling.Components.IComponent>();
            }
            set
            {
            }
        }

        #endregion

        #region IModelControlCommand Members

        public MouseManagerEvent MouseEvent
        {
            get
            {
                return new MouseManagerEvent(System.Windows.Forms.MouseButtons.None, System.Windows.Forms.Keys.None);
            }
            set
            {
            }
        }

        public ModelControl ModelControl
        {
            get
            {
                return this.modelControl;
            }
            set
            {
                this.modelControl = value;
            }
        }

        public System.Drawing.Point MouseDownPoint
        {
            get
            {
                return new System.Drawing.Point(0, 0);
            }
            set
            {
            }
        }

        public System.Drawing.Point MouseUpPoint
        {
            get
            {
                return new System.Drawing.Point(0, 0);
            }
            set
            {                
            }
        }

        public System.Drawing.Point MouseMovePoint
        {
            get
            {
                return new System.Drawing.Point(0, 0);
            }
            set
            {                
            }
        }

        public bool ExecuteImmediately
        {
            get
            {
                // TODO Надо ли?
                return true;
            }
            set
            {
            }
        }

        #endregion

        #region ICommand Members

        public void StartExecute()
        {
            this.modelControl.ModelContainer = createModelContainerDelegate.Invoke();
        }

        public void Execute()
        {
            //throw new NotImplementedException();
        }

        public void EndExecute()
        {
            //throw new NotImplementedException();
        }

        public bool CanUndo
        {
            get { return false; }
        }

        public bool Undo(ModelControl modelControl)
        {
            throw new NotImplementedException();
        }

        public bool Redo(ModelControl modelControl)
        {
            throw new NotImplementedException();
        }

        public string Name
        {
            get { return "Создать контейнер моделей"; }
        }

        #endregion

        #region ICloneable Members

        public object Clone()
        {
            CommandCreateModelContainer clone = new CommandCreateModelContainer(modelControl, createModelContainerDelegate);
            clone.MouseEvent = this.MouseEvent;
            clone.MouseDownPoint = this.MouseDownPoint;
            clone.MouseMovePoint = this.MouseMovePoint;
            clone.MouseUpPoint = this.MouseUpPoint;
            clone.ExecuteImmediately = this.ExecuteImmediately;
            return clone;
        }

        #endregion

        #region ICommand Members


        public bool IsNeedModelUpdate
        {
            get { return true; }
        }

        #endregion

        public override string ToString()
        {
            return this.Name;
        }

        #region ICommand Members

        private bool enabled = true;
        public bool Enabled
        {
            get
            {
                return enabled;
            }
            set
            {
                enabled = value;
            }
        }

        #endregion

        #region ICommand Members


        public bool IsNeedVisitorsUpdate
        {
            get { return false; }
        }

        #endregion
    }
}
